# --coding:utf-8--
import pymysql


class Connect(object):
    def __init__(self, db="basics_db"):
        try:
            # 连接数据库
            self.conn = pymysql.Connection(host="rm-bp19h77p0r89dnju94m.mysql.rds.aliyuncs.com",
                                           user="wzy",
                                           password="Wzy159753",
                                           port=3306,
                                           database=db,
                                           charset="utf8"
                                           )
            self.cursor = self.conn.cursor()  # 创建游标
            # self.cursor.execute("SELECT VERSION()")  # 查看MySQL版本
            # data = self.cursor.fetchone()
            # print(data)
            data = "link ok"
            print(data)
        except:
            data = "not link"
            print(data)

    def mysql_close(self):
        self.cursor.close()  # 关闭游标
        self.conn.close()  # 关闭连接


